import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MemberRefundVO, MemberRefundForm, MemberRefundQuery } from '@/api/system/memberRefund/types';

/**
 * 查询退费记录列表
 * @param query
 * @returns {*}
 */

export const listMemberRefund = (query?: MemberRefundQuery): AxiosPromise<MemberRefundVO[]> => {
  return request({
    url: '/system/memberRefund/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询退费记录详细
 * @param id
 */
export const getMemberRefund = (id: string | number): AxiosPromise<MemberRefundVO> => {
  return request({
    url: '/system/memberRefund/' + id,
    method: 'get'
  });
};

/**
 * 新增退费记录
 * @param data
 */
export const addMemberRefund = (data: MemberRefundForm) => {
  return request({
    url: '/system/memberRefund',
    method: 'post',
    data: data
  });
};

/**
 * 修改退费记录
 * @param data
 */
export const updateMemberRefund = (data: MemberRefundForm) => {
  return request({
    url: '/system/memberRefund',
    method: 'put'
  });
};

export const MemberRefundAudit = (query?: MemberRefundQuery): AxiosPromise<MemberRefundVO[]> => {
  return request({
    url: '/system/memberRefund/audit?' + 'id=' + query.id + '&checkStatus=' + query.checkStatus + '&cause=' + query.refundsCause,
    method: 'get'
  });
};

/**
 * 删除退费记录
 * @param id
 */
export const delMemberRefund = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/memberRefund/' + id,
    method: 'delete'
  });
};
